#!/usr/local/bin/python3
# -*- coding: UTF-8 -*-
"""
@author:apple
@file:li.py
@time:2022/03/10
"""
import requests
url = "https://www.pearvideo.com/video_1751913"


def load():
    ...
    id = url.split("_")[-1]

    # https://www.pearvideo.com/videoStatus.jsp?contId=1751913&mrd=0.21843328555599473
    video_url = f"https://www.pearvideo.com/videoStatus.jsp?contId={id}&mrd=0.21843328555599473"
    headers = {
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
        "Referer": url
    }

    response = requests.get(video_url, headers=headers)
    video_result = response.json()
    system_time = video_result["systemTime"]
    video_play_url = video_result["videoInfo"]["videos"]["srcUrl"]
    last_video_play_url = video_play_url.replace(system_time, f'cont-{id}')
    print(last_video_play_url)

    with open(f"{id}.mp4", mode="wb") as f:
        ...
        f.write(requests.get(last_video_play_url, headers).content)


if __name__ == '__main__':
    pass
    load()
